open Num
open Ratio

let string_to_num s = 
    let t = String.length s in
    let p = try String.index s '.' with _ -> 0 in
    if p <> 0 then
       (* Suppression de l'éventuelle virgule *)
       let n = (String.sub s 0 p)^(String.sub s (p+1) (t-p-1)) in
       (* Transformation en fraction *)
       num_of_string (n^"/1"^(String.make (t-p-1) '0'))
    else num_of_string(s)
